-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added warning when failing to update index cache #15014
base: master
Are you sure you want to change the base?
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a similar test, maybe we can take reuse that test to assert their stderr?
cargo/tests/testsuite/registry.rs
Lines 3053 to 3098 in 2939e96
fn readonly_registry_still_works() { | |
Package::new("foo", "0.1.0").publish(); | |
let p = project() | |
.file( | |
"Cargo.toml", | |
r#" | |
[package] | |
name = "a" | |
version = "0.5.0" | |
edition = "2015" | |
authors = [] | |
[dependencies] | |
foo = '0.1.0' | |
"#, | |
) | |
.file("src/lib.rs", "") | |
.build(); | |
p.cargo("generate-lockfile").run(); | |
p.cargo("fetch --locked").run(); | |
chmod_readonly(&paths::home(), true); | |
p.cargo("check").run(); | |
// make sure we un-readonly the files afterwards so "cargo clean" can remove them (#6934) | |
chmod_readonly(&paths::home(), false); | |
fn chmod_readonly(path: &Path, readonly: bool) { | |
for entry in t!(path.read_dir()) { | |
let entry = t!(entry); | |
let path = entry.path(); | |
if t!(entry.file_type()).is_dir() { | |
chmod_readonly(&path, readonly); | |
} else { | |
set_readonly(&path, readonly); | |
} | |
} | |
set_readonly(path, readonly); | |
} | |
fn set_readonly(path: &Path, readonly: bool) { | |
let mut perms = t!(path.metadata()).permissions(); | |
perms.set_readonly(readonly); | |
t!(fs::set_permissions(path, perms)); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I was able to use this to create a test based off of this in 9f2d0a3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shameless copied from #15026 (comment).
We generally ask that PRs are split into
- One commit that adds the test, showing the currently broken behavior (ie it passes)
- The fix commit that updates the test to pass with the change
This makes the diff between the two commits show the change in behavior
Mind doing that?
a50a73a
to
9f2d0a3
Compare
9f2d0a3
to
92ed0f1
Compare
#[cargo_test] | ||
#[cfg(not(windows))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder why it cannot be done on Windows. Is it possible to use Permissions::set_readonly
here?
authors = [] | ||
|
||
[dependencies] | ||
foo = '0.1.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add more than one dependency, so we know it really emits only once?
What does this PR try to resolve?
Fixes #13712
Adds a warning if there is an error updating the index cache.
It also attempts to avoid warning spam as requested in this comment
Below is an example output
How should we test and review this PR?
I tested this on my machine by manually changing the owner/permission of the index files
I wasn't quiet sure about the best way to add a test to the testsuite for this. 😅
If there is good way to create a test for this lmk